using System;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Collections;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using SumGam.Globals;
using SumGam.Structs;
using SumGam.Classes;
namespace SumGam
{
    public class TitleState : BaseState
    {
        double Ticks;
        Vector2 Pos;
        String DisplayText;
        Cue Music;
        public TitleState(string txt, Vector2 pos)
        {
            Ticks = 0;
            DisplayText = txt;
            Pos = pos;
            Music = Audio.Sounds.GetCue("Evrim_Sen_-_Human");
        }
        public override void OnEnter(BaseState laststate)
        {
            Ticks = 0;
            if (Music.IsStopped || Music.IsStopping || Music.IsPrepared)
            {
                Music = Audio.Sounds.GetCue("Evrim_Sen_-_Human");
                Music.Play();
            }
        }
        public override void Update()
        {
            if (Helpers.GetKeyState( Keys.Enter).JustPressed)
            {
                Helpers.SetMajorState(States.MainMenu);
            }
            else
            {
                Ticks = Ticks + 0.005;
                //PostProcessing.TitleScreenEffect.Threshold = (float)Math.Abs(Math.Sin(Ticks * 2) / 2);
            }
        }
        public override void Draw()
        {
            Rendering.spriteBatch.Begin();
            //PostProcessing.TitleScreenEffect.DrawTexture2D(Textures.TitleScreen);
            Rendering.spriteBatch.Draw(Textures.TitleScreen, new Vector2(0, 0), Color.White);
            Rendering.spriteBatch.DrawString(Fonts.TitleFont, DisplayText, Pos, Color.Firebrick);
            //Rendering.spriteBatch.Draw(Textures.TitleScreen, Vector2.Zero, Color.White);
            //Drawing.DrawBox(new Rectangle(100, 100, 100, 100), 10, Color.Blue, Color.White);
            Rendering.spriteBatch.End();
        }
        public override void OnExit(BaseState nextstate)
        {
            Music.Stop(AudioStopOptions.Immediate);
        }
    }
}